{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "28a5b483",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "339ba2f9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>col1</th>\n",
       "      <th>col2</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.672279</td>\n",
       "      <td>0.270493</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.488078</td>\n",
       "      <td>-1.435008</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.825495</td>\n",
       "      <td>0.882817</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.031446</td>\n",
       "      <td>-0.580082</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.808050</td>\n",
       "      <td>-0.501565</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>0.565617</td>\n",
       "      <td>0.590953</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>0.297622</td>\n",
       "      <td>-0.731616</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>0.046696</td>\n",
       "      <td>0.261755</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>0.990627</td>\n",
       "      <td>-0.855796</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>0.006826</td>\n",
       "      <td>-0.187526</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>0.769793</td>\n",
       "      <td>-0.373486</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>0.746767</td>\n",
       "      <td>-0.461971</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>0.377439</td>\n",
       "      <td>-0.816466</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>0.494147</td>\n",
       "      <td>-0.045123</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>0.928948</td>\n",
       "      <td>0.121328</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>0.395454</td>\n",
       "      <td>0.925953</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>0.973956</td>\n",
       "      <td>-0.573820</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>0.524415</td>\n",
       "      <td>0.052703</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>0.093613</td>\n",
       "      <td>2.207311</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>0.813308</td>\n",
       "      <td>0.391822</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        col1      col2\n",
       "0   0.672279  0.270493\n",
       "1   0.488078 -1.435008\n",
       "2   0.825495  0.882817\n",
       "3   0.031446 -0.580082\n",
       "4   0.808050 -0.501565\n",
       "5   0.565617  0.590953\n",
       "6   0.297622 -0.731616\n",
       "7   0.046696  0.261755\n",
       "8   0.990627 -0.855796\n",
       "9   0.006826 -0.187526\n",
       "10  0.769793 -0.373486\n",
       "11  0.746767 -0.461971\n",
       "12  0.377439 -0.816466\n",
       "13  0.494147 -0.045123\n",
       "14  0.928948  0.121328\n",
       "15  0.395454  0.925953\n",
       "16  0.973956 -0.573820\n",
       "17  0.524415  0.052703\n",
       "18  0.093613  2.207311\n",
       "19  0.813308  0.391822"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 041\n",
    "np.random.seed(99)\n",
    "s1 = pd.Series(np.random.rand(20))\n",
    "s2 = pd.Series(np.random.randn(20))\n",
    "\n",
    "# df = pd.concat([s1, s2])\n",
    "df = pd.concat([s1, s2], axis=1)\n",
    "df.columns = ['col1', 'col2']\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "3b9fcb5a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>col1</th>\n",
       "      <th>col2</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.672279</td>\n",
       "      <td>0.270493</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.825495</td>\n",
       "      <td>0.882817</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>0.565617</td>\n",
       "      <td>0.590953</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>0.046696</td>\n",
       "      <td>0.261755</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>0.928948</td>\n",
       "      <td>0.121328</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>0.395454</td>\n",
       "      <td>0.925953</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>0.524415</td>\n",
       "      <td>0.052703</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>0.093613</td>\n",
       "      <td>2.207311</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>0.813308</td>\n",
       "      <td>0.391822</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        col1      col2\n",
       "0   0.672279  0.270493\n",
       "2   0.825495  0.882817\n",
       "5   0.565617  0.590953\n",
       "7   0.046696  0.261755\n",
       "14  0.928948  0.121328\n",
       "15  0.395454  0.925953\n",
       "17  0.524415  0.052703\n",
       "18  0.093613  2.207311\n",
       "19  0.813308  0.391822"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 042\n",
    "df[(df['col2']>=0) & (df['col1']<=1)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "ea56b64a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>col1</th>\n",
       "      <th>col2</th>\n",
       "      <th>col3</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.672279</td>\n",
       "      <td>0.270493</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.488078</td>\n",
       "      <td>-1.435008</td>\n",
       "      <td>-1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.825495</td>\n",
       "      <td>0.882817</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.031446</td>\n",
       "      <td>-0.580082</td>\n",
       "      <td>-1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.808050</td>\n",
       "      <td>-0.501565</td>\n",
       "      <td>-1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>0.565617</td>\n",
       "      <td>0.590953</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>0.297622</td>\n",
       "      <td>-0.731616</td>\n",
       "      <td>-1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>0.046696</td>\n",
       "      <td>0.261755</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>0.990627</td>\n",
       "      <td>-0.855796</td>\n",
       "      <td>-1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>0.006826</td>\n",
       "      <td>-0.187526</td>\n",
       "      <td>-1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>0.769793</td>\n",
       "      <td>-0.373486</td>\n",
       "      <td>-1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>0.746767</td>\n",
       "      <td>-0.461971</td>\n",
       "      <td>-1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>0.377439</td>\n",
       "      <td>-0.816466</td>\n",
       "      <td>-1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>0.494147</td>\n",
       "      <td>-0.045123</td>\n",
       "      <td>-1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>0.928948</td>\n",
       "      <td>0.121328</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>0.395454</td>\n",
       "      <td>0.925953</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>0.973956</td>\n",
       "      <td>-0.573820</td>\n",
       "      <td>-1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>0.524415</td>\n",
       "      <td>0.052703</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>0.093613</td>\n",
       "      <td>2.207311</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>0.813308</td>\n",
       "      <td>0.391822</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        col1      col2  col3\n",
       "0   0.672279  0.270493     1\n",
       "1   0.488078 -1.435008    -1\n",
       "2   0.825495  0.882817     1\n",
       "3   0.031446 -0.580082    -1\n",
       "4   0.808050 -0.501565    -1\n",
       "5   0.565617  0.590953     1\n",
       "6   0.297622 -0.731616    -1\n",
       "7   0.046696  0.261755     1\n",
       "8   0.990627 -0.855796    -1\n",
       "9   0.006826 -0.187526    -1\n",
       "10  0.769793 -0.373486    -1\n",
       "11  0.746767 -0.461971    -1\n",
       "12  0.377439 -0.816466    -1\n",
       "13  0.494147 -0.045123    -1\n",
       "14  0.928948  0.121328     1\n",
       "15  0.395454  0.925953     1\n",
       "16  0.973956 -0.573820    -1\n",
       "17  0.524415  0.052703     1\n",
       "18  0.093613  2.207311     1\n",
       "19  0.813308  0.391822     1"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 043\n",
    "df['col3'] = df['col2'].map(lambda x: 1 if x>=0 else -1)\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "e0c3f83c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>col1</th>\n",
       "      <th>col2</th>\n",
       "      <th>col3</th>\n",
       "      <th>col4</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.672279</td>\n",
       "      <td>0.270493</td>\n",
       "      <td>1</td>\n",
       "      <td>0.270493</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.488078</td>\n",
       "      <td>-1.435008</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.825495</td>\n",
       "      <td>0.882817</td>\n",
       "      <td>1</td>\n",
       "      <td>0.882817</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.031446</td>\n",
       "      <td>-0.580082</td>\n",
       "      <td>-1</td>\n",
       "      <td>-0.580082</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.808050</td>\n",
       "      <td>-0.501565</td>\n",
       "      <td>-1</td>\n",
       "      <td>-0.501565</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>0.565617</td>\n",
       "      <td>0.590953</td>\n",
       "      <td>1</td>\n",
       "      <td>0.590953</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>0.297622</td>\n",
       "      <td>-0.731616</td>\n",
       "      <td>-1</td>\n",
       "      <td>-0.731616</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>0.046696</td>\n",
       "      <td>0.261755</td>\n",
       "      <td>1</td>\n",
       "      <td>0.261755</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>0.990627</td>\n",
       "      <td>-0.855796</td>\n",
       "      <td>-1</td>\n",
       "      <td>-0.855796</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>0.006826</td>\n",
       "      <td>-0.187526</td>\n",
       "      <td>-1</td>\n",
       "      <td>-0.187526</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>0.769793</td>\n",
       "      <td>-0.373486</td>\n",
       "      <td>-1</td>\n",
       "      <td>-0.373486</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>0.746767</td>\n",
       "      <td>-0.461971</td>\n",
       "      <td>-1</td>\n",
       "      <td>-0.461971</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>0.377439</td>\n",
       "      <td>-0.816466</td>\n",
       "      <td>-1</td>\n",
       "      <td>-0.816466</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>0.494147</td>\n",
       "      <td>-0.045123</td>\n",
       "      <td>-1</td>\n",
       "      <td>-0.045123</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>0.928948</td>\n",
       "      <td>0.121328</td>\n",
       "      <td>1</td>\n",
       "      <td>0.121328</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>0.395454</td>\n",
       "      <td>0.925953</td>\n",
       "      <td>1</td>\n",
       "      <td>0.925953</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>0.973956</td>\n",
       "      <td>-0.573820</td>\n",
       "      <td>-1</td>\n",
       "      <td>-0.573820</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>0.524415</td>\n",
       "      <td>0.052703</td>\n",
       "      <td>1</td>\n",
       "      <td>0.052703</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>0.093613</td>\n",
       "      <td>2.207311</td>\n",
       "      <td>1</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>0.813308</td>\n",
       "      <td>0.391822</td>\n",
       "      <td>1</td>\n",
       "      <td>0.391822</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        col1      col2  col3      col4\n",
       "0   0.672279  0.270493     1  0.270493\n",
       "1   0.488078 -1.435008    -1 -1.000000\n",
       "2   0.825495  0.882817     1  0.882817\n",
       "3   0.031446 -0.580082    -1 -0.580082\n",
       "4   0.808050 -0.501565    -1 -0.501565\n",
       "5   0.565617  0.590953     1  0.590953\n",
       "6   0.297622 -0.731616    -1 -0.731616\n",
       "7   0.046696  0.261755     1  0.261755\n",
       "8   0.990627 -0.855796    -1 -0.855796\n",
       "9   0.006826 -0.187526    -1 -0.187526\n",
       "10  0.769793 -0.373486    -1 -0.373486\n",
       "11  0.746767 -0.461971    -1 -0.461971\n",
       "12  0.377439 -0.816466    -1 -0.816466\n",
       "13  0.494147 -0.045123    -1 -0.045123\n",
       "14  0.928948  0.121328     1  0.121328\n",
       "15  0.395454  0.925953     1  0.925953\n",
       "16  0.973956 -0.573820    -1 -0.573820\n",
       "17  0.524415  0.052703     1  0.052703\n",
       "18  0.093613  2.207311     1  1.000000\n",
       "19  0.813308  0.391822     1  0.391822"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 044\n",
    "df['col4'] = df['col2'].clip(-1.0, 1.0)\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "7da3fbb8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1    -1.435008\n",
       "8    -0.855796\n",
       "12   -0.816466\n",
       "6    -0.731616\n",
       "3    -0.580082\n",
       "Name: col2, dtype: float64"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 045\n",
    "df['col2'].nlargest(5)\n",
    "df['col2'].nsmallest(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "dd57f215",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>col1</th>\n",
       "      <th>col2</th>\n",
       "      <th>col3</th>\n",
       "      <th>col4</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.672279</td>\n",
       "      <td>0.270493</td>\n",
       "      <td>1</td>\n",
       "      <td>0.270493</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1.160357</td>\n",
       "      <td>-1.164515</td>\n",
       "      <td>0</td>\n",
       "      <td>-0.729507</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1.985852</td>\n",
       "      <td>-0.281698</td>\n",
       "      <td>1</td>\n",
       "      <td>0.153310</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2.017299</td>\n",
       "      <td>-0.861780</td>\n",
       "      <td>0</td>\n",
       "      <td>-0.426772</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2.825348</td>\n",
       "      <td>-1.363345</td>\n",
       "      <td>-1</td>\n",
       "      <td>-0.928337</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>3.390966</td>\n",
       "      <td>-0.772392</td>\n",
       "      <td>0</td>\n",
       "      <td>-0.337384</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>3.688588</td>\n",
       "      <td>-1.504008</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1.069000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>3.735284</td>\n",
       "      <td>-1.242253</td>\n",
       "      <td>0</td>\n",
       "      <td>-0.807245</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>4.725912</td>\n",
       "      <td>-2.098048</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1.663040</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>4.732737</td>\n",
       "      <td>-2.285574</td>\n",
       "      <td>-2</td>\n",
       "      <td>-1.850566</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>5.502530</td>\n",
       "      <td>-2.659060</td>\n",
       "      <td>-3</td>\n",
       "      <td>-2.224052</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>6.249297</td>\n",
       "      <td>-3.121031</td>\n",
       "      <td>-4</td>\n",
       "      <td>-2.686023</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>6.626736</td>\n",
       "      <td>-3.937498</td>\n",
       "      <td>-5</td>\n",
       "      <td>-3.502489</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>7.120884</td>\n",
       "      <td>-3.982621</td>\n",
       "      <td>-6</td>\n",
       "      <td>-3.547613</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>8.049832</td>\n",
       "      <td>-3.861293</td>\n",
       "      <td>-5</td>\n",
       "      <td>-3.426285</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>8.445286</td>\n",
       "      <td>-2.935340</td>\n",
       "      <td>-4</td>\n",
       "      <td>-2.500332</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>9.419243</td>\n",
       "      <td>-3.509160</td>\n",
       "      <td>-5</td>\n",
       "      <td>-3.074152</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>9.943657</td>\n",
       "      <td>-3.456457</td>\n",
       "      <td>-4</td>\n",
       "      <td>-3.021449</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>10.037270</td>\n",
       "      <td>-1.249146</td>\n",
       "      <td>-3</td>\n",
       "      <td>-2.021449</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>10.850579</td>\n",
       "      <td>-0.857324</td>\n",
       "      <td>-2</td>\n",
       "      <td>-1.629627</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         col1      col2  col3      col4\n",
       "0    0.672279  0.270493     1  0.270493\n",
       "1    1.160357 -1.164515     0 -0.729507\n",
       "2    1.985852 -0.281698     1  0.153310\n",
       "3    2.017299 -0.861780     0 -0.426772\n",
       "4    2.825348 -1.363345    -1 -0.928337\n",
       "5    3.390966 -0.772392     0 -0.337384\n",
       "6    3.688588 -1.504008    -1 -1.069000\n",
       "7    3.735284 -1.242253     0 -0.807245\n",
       "8    4.725912 -2.098048    -1 -1.663040\n",
       "9    4.732737 -2.285574    -2 -1.850566\n",
       "10   5.502530 -2.659060    -3 -2.224052\n",
       "11   6.249297 -3.121031    -4 -2.686023\n",
       "12   6.626736 -3.937498    -5 -3.502489\n",
       "13   7.120884 -3.982621    -6 -3.547613\n",
       "14   8.049832 -3.861293    -5 -3.426285\n",
       "15   8.445286 -2.935340    -4 -2.500332\n",
       "16   9.419243 -3.509160    -5 -3.074152\n",
       "17   9.943657 -3.456457    -4 -3.021449\n",
       "18  10.037270 -1.249146    -3 -2.021449\n",
       "19  10.850579 -0.857324    -2 -1.629627"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 046\n",
    "df.cumsum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "7d68dde9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "-0.1163246074082501"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 047\n",
    "df['col2'].median()\n",
    "df['col2'].quantile()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "991c16ef",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>col1</th>\n",
       "      <th>col2</th>\n",
       "      <th>col3</th>\n",
       "      <th>col4</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.672279</td>\n",
       "      <td>0.270493</td>\n",
       "      <td>1</td>\n",
       "      <td>0.270493</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.825495</td>\n",
       "      <td>0.882817</td>\n",
       "      <td>1</td>\n",
       "      <td>0.882817</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>0.565617</td>\n",
       "      <td>0.590953</td>\n",
       "      <td>1</td>\n",
       "      <td>0.590953</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>0.046696</td>\n",
       "      <td>0.261755</td>\n",
       "      <td>1</td>\n",
       "      <td>0.261755</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>0.928948</td>\n",
       "      <td>0.121328</td>\n",
       "      <td>1</td>\n",
       "      <td>0.121328</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>0.395454</td>\n",
       "      <td>0.925953</td>\n",
       "      <td>1</td>\n",
       "      <td>0.925953</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>0.524415</td>\n",
       "      <td>0.052703</td>\n",
       "      <td>1</td>\n",
       "      <td>0.052703</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>0.093613</td>\n",
       "      <td>2.207311</td>\n",
       "      <td>1</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>0.813308</td>\n",
       "      <td>0.391822</td>\n",
       "      <td>1</td>\n",
       "      <td>0.391822</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        col1      col2  col3      col4\n",
       "0   0.672279  0.270493     1  0.270493\n",
       "2   0.825495  0.882817     1  0.882817\n",
       "5   0.565617  0.590953     1  0.590953\n",
       "7   0.046696  0.261755     1  0.261755\n",
       "14  0.928948  0.121328     1  0.121328\n",
       "15  0.395454  0.925953     1  0.925953\n",
       "17  0.524415  0.052703     1  0.052703\n",
       "18  0.093613  2.207311     1  1.000000\n",
       "19  0.813308  0.391822     1  0.391822"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 048\n",
    "df[df['col2']>0]\n",
    "df.query(\"col2>0\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "cf3ae96f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'col1': {0: 0.6722785586307918,\n",
       "  1: 0.4880783992405837,\n",
       "  2: 0.8254951740358963,\n",
       "  3: 0.031446387626298145,\n",
       "  4: 0.8080499633648477},\n",
       " 'col2': {0: 0.2704927820664171,\n",
       "  1: -1.4350081438664337,\n",
       "  2: 0.8828171461847689,\n",
       "  3: -0.5800816639402705,\n",
       "  4: -0.5015653039496065},\n",
       " 'col3': {0: 1, 1: -1, 2: 1, 3: -1, 4: -1},\n",
       " 'col4': {0: 0.2704927820664171,\n",
       "  1: -1.0,\n",
       "  2: 0.8828171461847689,\n",
       "  3: -0.5800816639402705,\n",
       "  4: -0.5015653039496065}}"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 049\n",
    "df.head(5).to_dict()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "cef14df0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'<table border=\"1\" class=\"dataframe\">\\n  <thead>\\n    <tr style=\"text-align: right;\">\\n      <th></th>\\n      <th>col1</th>\\n      <th>col2</th>\\n      <th>col3</th>\\n      <th>col4</th>\\n    </tr>\\n  </thead>\\n  <tbody>\\n    <tr>\\n      <th>0</th>\\n      <td>0.672279</td>\\n      <td>0.270493</td>\\n      <td>1</td>\\n      <td>0.270493</td>\\n    </tr>\\n    <tr>\\n      <th>1</th>\\n      <td>0.488078</td>\\n      <td>-1.435008</td>\\n      <td>-1</td>\\n      <td>-1.000000</td>\\n    </tr>\\n    <tr>\\n      <th>2</th>\\n      <td>0.825495</td>\\n      <td>0.882817</td>\\n      <td>1</td>\\n      <td>0.882817</td>\\n    </tr>\\n    <tr>\\n      <th>3</th>\\n      <td>0.031446</td>\\n      <td>-0.580082</td>\\n      <td>-1</td>\\n      <td>-0.580082</td>\\n    </tr>\\n    <tr>\\n      <th>4</th>\\n      <td>0.808050</td>\\n      <td>-0.501565</td>\\n      <td>-1</td>\\n      <td>-0.501565</td>\\n    </tr>\\n  </tbody>\\n</table>'"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 050\n",
    "df.head(5).to_html()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "13343b34",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.672279</td>\n",
       "      <td>0.488078</td>\n",
       "      <td>0.825495</td>\n",
       "      <td>0.031446</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.377439</td>\n",
       "      <td>0.494147</td>\n",
       "      <td>0.928948</td>\n",
       "      <td>0.395454</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          A         B         C         D\n",
       "0  0.672279  0.488078  0.825495  0.031446\n",
       "3  0.377439  0.494147  0.928948  0.395454"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 051\n",
    "np.random.seed(99)\n",
    "\n",
    "df = pd.DataFrame(np.random.rand(10,4), columns=list('ABCD'))\n",
    "\n",
    "df.loc[df['C']>0.8]\n",
    "# df[df['C']>0.8]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "0e64bcf6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.672279</td>\n",
       "      <td>0.488078</td>\n",
       "      <td>0.825495</td>\n",
       "      <td>0.031446</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.377439</td>\n",
       "      <td>0.494147</td>\n",
       "      <td>0.928948</td>\n",
       "      <td>0.395454</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>0.828043</td>\n",
       "      <td>0.221577</td>\n",
       "      <td>0.644835</td>\n",
       "      <td>0.095182</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          A         B         C         D\n",
       "0  0.672279  0.488078  0.825495  0.031446\n",
       "3  0.377439  0.494147  0.928948  0.395454\n",
       "6  0.828043  0.221577  0.644835  0.095182"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 052\n",
    "df[(df['C']>0.3) & (df['D']<0.7)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "ffabe138",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "A    0.672279\n",
      "B    0.488078\n",
      "C    0.825495\n",
      "D    0.031446\n",
      "Name: 0, dtype: float64\n",
      "A    0.808050\n",
      "B    0.565617\n",
      "C    0.297622\n",
      "D    0.046696\n",
      "Name: 1, dtype: float64\n",
      "A    0.990627\n",
      "B    0.006826\n",
      "C    0.769793\n",
      "D    0.746767\n",
      "Name: 2, dtype: float64\n",
      "A    0.377439\n",
      "B    0.494147\n",
      "C    0.928948\n",
      "D    0.395454\n",
      "Name: 3, dtype: float64\n",
      "A    0.973956\n",
      "B    0.524415\n",
      "C    0.093613\n",
      "D    0.813308\n",
      "Name: 4, dtype: float64\n"
     ]
    }
   ],
   "source": [
    "# 053\n",
    "for index, row in df.head(5).iterrows():\n",
    "    print(row)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "a6b8007f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.672279</td>\n",
       "      <td>0.488078</td>\n",
       "      <td>0.825495</td>\n",
       "      <td>0.031446</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.808050</td>\n",
       "      <td>0.565617</td>\n",
       "      <td>0.297622</td>\n",
       "      <td>0.046696</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.990627</td>\n",
       "      <td>0.006826</td>\n",
       "      <td>0.769793</td>\n",
       "      <td>0.746767</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.377439</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.928948</td>\n",
       "      <td>0.395454</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.973956</td>\n",
       "      <td>0.524415</td>\n",
       "      <td>0.093613</td>\n",
       "      <td>0.813308</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>0.211687</td>\n",
       "      <td>0.554346</td>\n",
       "      <td>0.292269</td>\n",
       "      <td>0.816142</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>0.828043</td>\n",
       "      <td>0.221577</td>\n",
       "      <td>0.644835</td>\n",
       "      <td>0.095182</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>0.411663</td>\n",
       "      <td>0.096865</td>\n",
       "      <td>0.144011</td>\n",
       "      <td>0.212196</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>0.476656</td>\n",
       "      <td>0.077614</td>\n",
       "      <td>0.235044</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>0.898644</td>\n",
       "      <td>0.552234</td>\n",
       "      <td>0.167547</td>\n",
       "      <td>0.928878</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          A         B         C         D\n",
       "0  0.672279  0.488078  0.825495  0.031446\n",
       "1  0.808050  0.565617  0.297622  0.046696\n",
       "2  0.990627  0.006826  0.769793  0.746767\n",
       "3  0.377439       NaN  0.928948  0.395454\n",
       "4  0.973956  0.524415  0.093613  0.813308\n",
       "5  0.211687  0.554346  0.292269  0.816142\n",
       "6  0.828043  0.221577  0.644835  0.095182\n",
       "7  0.411663  0.096865  0.144011  0.212196\n",
       "8  0.476656  0.077614  0.235044       NaN\n",
       "9  0.898644  0.552234  0.167547  0.928878"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 054\n",
    "df.iloc[3, 1] = np.NAN\n",
    "df.loc[8, 'D'] = np.NAN\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "d15f3b3e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.672279</td>\n",
       "      <td>0.488078</td>\n",
       "      <td>0.825495</td>\n",
       "      <td>0.031446</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.808050</td>\n",
       "      <td>0.565617</td>\n",
       "      <td>0.297622</td>\n",
       "      <td>0.046696</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.990627</td>\n",
       "      <td>0.006826</td>\n",
       "      <td>0.769793</td>\n",
       "      <td>0.746767</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.973956</td>\n",
       "      <td>0.524415</td>\n",
       "      <td>0.093613</td>\n",
       "      <td>0.813308</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>0.211687</td>\n",
       "      <td>0.554346</td>\n",
       "      <td>0.292269</td>\n",
       "      <td>0.816142</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>0.828043</td>\n",
       "      <td>0.221577</td>\n",
       "      <td>0.644835</td>\n",
       "      <td>0.095182</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>0.411663</td>\n",
       "      <td>0.096865</td>\n",
       "      <td>0.144011</td>\n",
       "      <td>0.212196</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>0.898644</td>\n",
       "      <td>0.552234</td>\n",
       "      <td>0.167547</td>\n",
       "      <td>0.928878</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          A         B         C         D\n",
       "0  0.672279  0.488078  0.825495  0.031446\n",
       "1  0.808050  0.565617  0.297622  0.046696\n",
       "2  0.990627  0.006826  0.769793  0.746767\n",
       "4  0.973956  0.524415  0.093613  0.813308\n",
       "5  0.211687  0.554346  0.292269  0.816142\n",
       "6  0.828043  0.221577  0.644835  0.095182\n",
       "7  0.411663  0.096865  0.144011  0.212196\n",
       "9  0.898644  0.552234  0.167547  0.928878"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 055\n",
    "df2 = df.dropna()\n",
    "df2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "5e5edd2c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.672279</td>\n",
       "      <td>0.488078</td>\n",
       "      <td>0.825495</td>\n",
       "      <td>0.031446</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.808050</td>\n",
       "      <td>0.565617</td>\n",
       "      <td>0.297622</td>\n",
       "      <td>0.046696</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.990627</td>\n",
       "      <td>0.006826</td>\n",
       "      <td>0.769793</td>\n",
       "      <td>0.746767</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.973956</td>\n",
       "      <td>0.524415</td>\n",
       "      <td>0.093613</td>\n",
       "      <td>0.813308</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.211687</td>\n",
       "      <td>0.554346</td>\n",
       "      <td>0.292269</td>\n",
       "      <td>0.816142</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>0.828043</td>\n",
       "      <td>0.221577</td>\n",
       "      <td>0.644835</td>\n",
       "      <td>0.095182</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>0.411663</td>\n",
       "      <td>0.096865</td>\n",
       "      <td>0.144011</td>\n",
       "      <td>0.212196</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>0.898644</td>\n",
       "      <td>0.552234</td>\n",
       "      <td>0.167547</td>\n",
       "      <td>0.928878</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          A         B         C         D\n",
       "0  0.672279  0.488078  0.825495  0.031446\n",
       "1  0.808050  0.565617  0.297622  0.046696\n",
       "2  0.990627  0.006826  0.769793  0.746767\n",
       "3  0.973956  0.524415  0.093613  0.813308\n",
       "4  0.211687  0.554346  0.292269  0.816142\n",
       "5  0.828043  0.221577  0.644835  0.095182\n",
       "6  0.411663  0.096865  0.144011  0.212196\n",
       "7  0.898644  0.552234  0.167547  0.928878"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 056\n",
    "df2 = df.dropna()\n",
    "df2 = df2.reset_index(drop=True)\n",
    "df2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "893e989e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "A    0\n",
       "B    1\n",
       "C    0\n",
       "D    1\n",
       "dtype: int64"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 057\n",
    "df.isnull().sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "a7f00402",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.672279</td>\n",
       "      <td>0.488078</td>\n",
       "      <td>0.825495</td>\n",
       "      <td>0.031446</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.808050</td>\n",
       "      <td>0.565617</td>\n",
       "      <td>0.297622</td>\n",
       "      <td>0.046696</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.990627</td>\n",
       "      <td>0.006826</td>\n",
       "      <td>0.769793</td>\n",
       "      <td>0.746767</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.377439</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.928948</td>\n",
       "      <td>0.395454</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.973956</td>\n",
       "      <td>0.524415</td>\n",
       "      <td>0.093613</td>\n",
       "      <td>0.813308</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>0.211687</td>\n",
       "      <td>0.554346</td>\n",
       "      <td>0.292269</td>\n",
       "      <td>0.816142</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>0.828043</td>\n",
       "      <td>0.221577</td>\n",
       "      <td>0.644835</td>\n",
       "      <td>0.095182</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>0.411663</td>\n",
       "      <td>0.096865</td>\n",
       "      <td>0.144011</td>\n",
       "      <td>0.212196</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>0.476656</td>\n",
       "      <td>0.077614</td>\n",
       "      <td>0.235044</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>0.898644</td>\n",
       "      <td>0.552234</td>\n",
       "      <td>0.167547</td>\n",
       "      <td>0.928878</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          A         B         C         D\n",
       "0  0.672279  0.488078  0.825495  0.031446\n",
       "1  0.808050  0.565617  0.297622  0.046696\n",
       "2  0.990627  0.006826  0.769793  0.746767\n",
       "3  0.377439  0.000000  0.928948  0.395454\n",
       "4  0.973956  0.524415  0.093613  0.813308\n",
       "5  0.211687  0.554346  0.292269  0.816142\n",
       "6  0.828043  0.221577  0.644835  0.095182\n",
       "7  0.411663  0.096865  0.144011  0.212196\n",
       "8  0.476656  0.077614  0.235044  0.000000\n",
       "9  0.898644  0.552234  0.167547  0.928878"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 058\n",
    "df = df.fillna(0)\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "a5f51c3b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>D</th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.031446</td>\n",
       "      <td>0.672279</td>\n",
       "      <td>0.488078</td>\n",
       "      <td>0.825495</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.046696</td>\n",
       "      <td>0.808050</td>\n",
       "      <td>0.565617</td>\n",
       "      <td>0.297622</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.746767</td>\n",
       "      <td>0.990627</td>\n",
       "      <td>0.006826</td>\n",
       "      <td>0.769793</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.395454</td>\n",
       "      <td>0.377439</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.928948</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.813308</td>\n",
       "      <td>0.973956</td>\n",
       "      <td>0.524415</td>\n",
       "      <td>0.093613</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>0.816142</td>\n",
       "      <td>0.211687</td>\n",
       "      <td>0.554346</td>\n",
       "      <td>0.292269</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>0.095182</td>\n",
       "      <td>0.828043</td>\n",
       "      <td>0.221577</td>\n",
       "      <td>0.644835</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>0.212196</td>\n",
       "      <td>0.411663</td>\n",
       "      <td>0.096865</td>\n",
       "      <td>0.144011</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.476656</td>\n",
       "      <td>0.077614</td>\n",
       "      <td>0.235044</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>0.928878</td>\n",
       "      <td>0.898644</td>\n",
       "      <td>0.552234</td>\n",
       "      <td>0.167547</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          D         A         B         C\n",
       "0  0.031446  0.672279  0.488078  0.825495\n",
       "1  0.046696  0.808050  0.565617  0.297622\n",
       "2  0.746767  0.990627  0.006826  0.769793\n",
       "3  0.395454  0.377439  0.000000  0.928948\n",
       "4  0.813308  0.973956  0.524415  0.093613\n",
       "5  0.816142  0.211687  0.554346  0.292269\n",
       "6  0.095182  0.828043  0.221577  0.644835\n",
       "7  0.212196  0.411663  0.096865  0.144011\n",
       "8  0.000000  0.476656  0.077614  0.235044\n",
       "9  0.928878  0.898644  0.552234  0.167547"
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 059\n",
    "df = df[['D',\"A\",'B','C']]\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "id": "1840870a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.672279</td>\n",
       "      <td>0.488078</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.808050</td>\n",
       "      <td>0.565617</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.990627</td>\n",
       "      <td>0.006826</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.377439</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.973956</td>\n",
       "      <td>0.524415</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>0.211687</td>\n",
       "      <td>0.554346</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>0.828043</td>\n",
       "      <td>0.221577</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>0.411663</td>\n",
       "      <td>0.096865</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>0.476656</td>\n",
       "      <td>0.077614</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>0.898644</td>\n",
       "      <td>0.552234</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          A         B\n",
       "0  0.672279  0.488078\n",
       "1  0.808050  0.565617\n",
       "2  0.990627  0.006826\n",
       "3  0.377439  0.000000\n",
       "4  0.973956  0.524415\n",
       "5  0.211687  0.554346\n",
       "6  0.828043  0.221577\n",
       "7  0.411663  0.096865\n",
       "8  0.476656  0.077614\n",
       "9  0.898644  0.552234"
      ]
     },
     "execution_count": 54,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 60\n",
    "df1 = df.drop(columns=['D','C'])\n",
    "df1"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
